Package edu.claflin.finder.io.graph
Class SimpleGraphIO
java.lang.Object
edu.claflin.finder.io.graph.SimpleGraphIO
- All Implemented Interfaces:
GraphReader,GraphWriter
A class for reading and writing graphs.
- Version:
- 3.1.2 February 2, 2016
- Author:
- Charles Allen Schultz II
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseGraph(File source, boolean undirected) Reads a graph from memory.private static booleanTests to see if a File is a valid graph file.voidwriteGraph(Graph toWrite) Writes graphs to memory.
-
Constructor Details
-
SimpleGraphIO
public SimpleGraphIO()
-
-
Method Details
-
parseGraph
Reads a graph from memory. Reads simple tab delimited graphs. A graph file consists of an edge on each line with a tab delimiting the two nodes joined by the edge and followed by a floating point value representing the edge weight.- Specified by:
parseGraphin interfaceGraphReader- Parameters:
source- the File object representing the graph.undirected- a boolean indicating if the graph should be interpreted as undirected.- Returns:
- the Graph object parsed from the file.
-
writeGraph
Writes graphs to memory. Writes simple tab delimited graphs. Outputs to the disk a graph. Each line of the outputted graph represents an edge. The two nodes joined by the edge are delimited by a tab.- Specified by:
writeGraphin interfaceGraphWriter- Parameters:
toWrite- theGraphobject to write to a file.
-
testFile
Tests to see if a File is a valid graph file. Currently only tests by checking to ensure the provided file is not a directory.- Parameters:
file- the File to test.- Returns:
- the boolean value representing if the file is valid.
-